#include<iostream>
#include<deque>
using namespace std;

const int N=1e6+10;
typedef long long ll;
int n, k;
ll arr[N];

int main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>arr[i];
	
	deque<ll> q;
	
	for(int i=1; i<=n; i++)
	{
		while(q.size() && arr[i] <= arr[q.back()]) q.pop_back();
		
		q.push_back(i);
		
		if(q.back() - q.front() + 1 > k) q.pop_front();
		
		if(i>=k) cout<<arr[q.front()]<<endl;
 	}
 	
	return 0;
}
